<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/12
 * Time: 11:40
 */
namespace App\Repositories;

use App\Models\Address;

class AddressRepository
{
    /**
     * @param array $params
     * @return mixed
     */
    public function create(array $params)
    {
        return Address::create($params);
    }

    public function insertGetId(array $params)
    {
        return Address::insertGetId($params);
    }

    public function byId($id)
    {
        return Address::find($id);
    }

    public function byName($name)
    {
        return Address::where('name', $name)->first();
    }

    public function byNamePid($name, $pid = 0)
    {
        return Address::where([
            'name' => $name,
            'pid' => $pid,
        ])->first();
    }


}